<template>
  <div>
    <van-nav-bar title="我发布的病友圈" left-text="" left-arrow @click-left="router.go(-1)" />
    <div v-for="(item, index) in patientData" :key="index" class="listItem">
      <div class="title">
        <h3>标题：{{ item.title }}</h3>
        <div class="HB">
          <img src="../../assets/images/image/hdpi/h_currency.png" alt="" />
          <span>悬赏数：{{ item.amount }}</span>
        </div>
      </div>
    
      <div class="detail">详情：{{ item.detail }}</div>
      <button @click="gopatient(item.sickCircleId)">去查看评论</button>
    </div>
  </div>
</template>
<script setup lang="ts">
import { findMySickCircleList } from '../../api/search'
import { onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'

const userId = ref(parseInt(localStorage.getItem('userId') as string))
const sessionId = ref(JSON.parse(localStorage.getItem('sessionId') as string))
const patientData:any= ref({})
const findMySickCircleList1 = async () => {
  const res = await findMySickCircleList(userId.value, sessionId.value, {
    page: 1,
    count: 5
  })
  console.log('我发布的病友圈', res)
  patientData.value = res.data.result
}
findMySickCircleList1()
const router = useRouter()
const gopatient = (sickCircleId: number) => {
  console.log(sickCircleId)
  localStorage.setItem('sickCircleId', JSON.stringify(sickCircleId))
  router.push('/commentlist')
}
</script>

<style>
@import './mypatient.scss';
</style>
